<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>


    <script>
        // let multiply = function(num1, num2) {
        //     if (isNaN(num1) || isNaN(num2)) return '';
        //     if (num1 === '0' || num2 === '0') return '0';

        //     let l1 = num1.length,
        //         l2 = num2.length;

        //     let result = [];

        //     for (let i = l1 - 1; i >= 0; i--) {
        //         for (let j = l2 - 1; j >= 0; j--) {
        //             let index1 = i + j;
        //             let index2 = i + j + 1;

        //             let product = num1[i] * num2[j] + (result[index2] || 0);
        //             result[index2] = product % 10;
        //             result[index1] = Math.floor(product / 10) + (result[index1] || 0);
        //         }
        //     }
        //     return result.join('').replace(/^0+/, '');
        // }

        // console.log(multiply('123', '234')) //28782
        // function multiply(num1, num2) {
        //     if (isNaN(num1) || isNaN(num2)) return '';
        //     if (num1 === 0 || num2 === 0) return '0';
        //     let len1 = num1.length;
        //     let len2 = num2.length;
        //     let result = [];
        //     for (let i = len1 - 1; i >= 0; i--) {
        //         for (let j = len2 - 1; j >= 0; j--) {
        //             const index1 = i + j;
        //             const index2 = i + j + 1;
        //             const middle = num1[i] * num2[j] + (result[index2] || 0);
        //             result[index2] = middle % 10;
        //             result[index1] = Math.floor(middle / 10) + (result[index1] || 0);
        //         }
        //     }
        //     return result.join('').replace(/^0+/, '');
        // }
    </script>
</body>

</html>